﻿using BaseData.DomainLib.AggregatesModel.WorkstationAggregate;
using Microsoft.EntityFrameworkCore;
using Swimj.DomainLib.SeedWork;

namespace BaseData.InfrastructureLib.Repositories;

public class WorkstationRepository : IWorkstationRepository
{
    private readonly BaseDataDbContext _dbContext;
    public IUnitOfWork UnitOfWork => _dbContext;

    public WorkstationRepository(BaseDataDbContext dbContext)
    {
        _dbContext = dbContext;
    }

    public Workstation Add(Workstation workstation)
    {
        return _dbContext.Workstations.Add(workstation).Entity;
    }

    public Task<Workstation?> Get(int requestId)
    {
        return _dbContext.Workstations.FirstOrDefaultAsync(i => i.Id == requestId);
    }
}